package com.bwie.controller;

import com.bwie.pojo.ServiceItem;
import com.bwie.service.CouponService;
import com.bwie.service.CustomerAddressService;
import com.bwie.service.ServiceItemService;
import com.bwie.service.ServiceTypeService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/7/11 10:08 08
 */
@RestController
@RequestMapping("/item")
public class ItemController {
    @Autowired
    private ServiceItemService serviceItemService;
    @Autowired
    private ServiceTypeService serviceTypeService;
    @Autowired
    private CouponService couponService;
    @Autowired
    private CustomerAddressService customerAddressService;


    @ApiOperation("分页列表")
    @PostMapping("/getItemPage")
    public R getItemPage(@RequestBody PageInfoVo pageInfoVo){
        return serviceItemService.getItemPage(pageInfoVo);
    }

    @ApiOperation("获取服务项下拉框")
    @PostMapping("/getItemByTypeId/{typeId}")
    public R getItemByTypeId(@PathVariable("typeId")Integer typeId){
        return serviceItemService.getItemByTypeId(typeId);
    }

    @ApiOperation("获取服务类型列表")
    @PostMapping("/getTypeList")
    public R getTypeList(){
        return serviceTypeService.getTypeList();
    }

    @ApiOperation("新建服务项")
    @PostMapping("/addItem")
    public  R addItem(@RequestBody ServiceItem serviceItem){
        return serviceItemService.addItem(serviceItem);
    }

    @ApiOperation("上传图片")
    @PostMapping("/upload")
    public R upload(@RequestPart("file")MultipartFile file) throws IOException {
        return serviceItemService.upload(file);
    }


    @ApiOperation("获取优惠卷")
    @PostMapping("/getCouponList/{customerId}")
    public R getCouponList(@PathVariable("customerId")Integer customerId){
        return couponService.getCouponList(customerId);
    }

    @ApiOperation("获取客户地址")
    @PostMapping("/getAddress/{customerId}")
    public R getAddress(@PathVariable("customerId")Integer customerId){
        return customerAddressService.getAddress(customerId);
    }




}
